import {ElMessage,ElMessageBox} from 'element-plus'
import config from "@/common/config.js"
export default function () {
	const api = inject('api');//api请求
	const defaultImg = 'default.jpg';

	const route = useRoute();//用来获取url参数
	const router = useRouter();//用来页面跳转
	
	//复制内容
	const copy = value=>{
		var oInput = document.createElement('input'); //创建一个隐藏input（重要！）
		oInput.value = value; //赋值
		document.body.appendChild(oInput);
		oInput.select(); // 选择对象
		document.execCommand("Copy"); // 执行浏览器复制命令
		oInput.className = 'oInput';
		oInput.style.display = 'none';
		ElMessage({
			message: '复制成功',
			type: 'success'
		})
	}
	
	//消息提示操作
	const aTips = (msg,callback,)=>{
		ElMessageBox({
			title: '系统提示',
			message: msg,
			showCancelButton: true,
			confirmButtonText: '确定',
			cancelButtonText: '取消',
			dangerouslyUseHTMLString: true,
		}).then(action => {
			typeof callback == 'function' && callback(action);
		}).catch(e=>{
			console.log(e);
		})
	}
	return {
		route,
		router,
		copy,
		aTips,
		defaultImg,
		ElMessage,
		api,
		config
	}
}